<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增排水管养')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-maintainence-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">清单状态：</label>
            <div class="col-sm-8">
                <select name="status" class="form-control m-b" th:with="type=${@dict.getType('sys_pipe_status')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题来源：</label>
            <div class="col-sm-8">
                <input name="problemSources" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">上报时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="reportTime" class="form-control" placeholder="yyyy-MM-dd HH:mm" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系人：</label>
            <div class="col-sm-8">
                <input name="contact" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">联系电话：</label>
            <div class="col-sm-8">
                <input name="telephone" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">大类：</label>
            <div class="col-sm-8">
                <input name="bigClassName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">小类：</label>
            <div class="col-sm-8">
                <input name="smallClassName" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">关联办件号：</label>
            <div class="col-sm-8">
                <input name="associatedOfficeNum" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题描述：</label>
            <div class="col-sm-8">
                <input name="problemDescription" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">是否疑难件：</label>
            <div class="col-sm-8">
                <select name="isDifficultParts" class="form-control m-b" th:with="type=${@dict.getType('sys_yes_no')}">
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">解决期限：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="solveDeadline" class="form-control" placeholder="yyyy-MM-dd HH:mm" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">到期时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="expirationTime" class="form-control" placeholder="yyyy-MM-dd HH:mm" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">长度(m)：</label>
            <div class="col-sm-8">
                <input name="length" class="form-control two-decimal" type="text" id="length">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">宽度(m)：</label>
            <div class="col-sm-8">
                <input name="width" class="form-control two-decimal" type="text" id="width">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">面积(m^2)：</label>
            <div class="col-sm-8">
                <input name="area" class="form-control" type="text" readonly id="area">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">所属辖区：</label>
            <div class="col-sm-8">
                <input name="memberArea" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">问题地点：</label>
            <div class="col-sm-8">
                <input name="issuePalce" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">处理部门：</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" type="text" name="solveDepartment" onclick="selectDeptTree()"
                           id="treeName" required>
                    <span class="input-group-addon"><i class="fa fa-search"></i></span>
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">备注：</label>
            <div class="col-sm-8">
                <input name="remark" class="form-control" type="text">
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">抄送人：</label>
            <div class="col-sm-8">
                <input name="copyIds" class="form-control" type="text" onclick="selectUser()">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<script type="text/javascript">
    var prefix = ctx + "process/maintainence"
    $("#form-maintainence-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/add", $('#form-maintainence-add').serialize());
        }
    }

    $("input[name='reportTime']").datetimepicker({
        // format: "yyyy-mm-dd HH:mm",
        // minView: "month",
        autoclose: true,
        startDate: new Date()
    });

    $("input[name='solveDeadline']").datetimepicker({
        autoclose: true,
        startDate: new Date()
    });

    $("input[name='expirationTime']").datetimepicker({
        autoclose: true,
        startDate: new Date()
    });

    /*用户管理-新增-选择部门树*/
    function selectDeptTree() {
        var treeId = $("#treeId").val();
        var deptId = $.common.isEmpty(treeId) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    };

    function doSubmit(index, layero) {
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    };

    /* 分配用户-选择用户 */
    function selectUser() {
        var url = prefix + '/selectUser';
        $.modal.open("选择抄送用户", url);
    };

    $(".two-decimal").on("input", function (e) {
        debugger
        e.target.value = e.target.value.replace(/[^\d.]/g, ""); //清除"数字"和"."以外的字符
        e.target.value = e.target.value.replace(/^\./g, ""); //验证第一个字符是数字而不是.
        e.target.value = e.target.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的.
        e.target.value = e.target.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");//只允许输入一个小数点
        e.target.value = e.target.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3'); //只能输入两个小数

        //获取值 赋值给面积
        var width = Number.isNaN(parseFloat($("#width").val())) == true ? 0.00 : parseFloat($("#width").val());
        var length = Number.isNaN(parseFloat($("#length").val())) == true ? 0.00 : parseFloat($("#length").val());
        $("#area").val(length * width);
    });


</script>
</body>
</html>